/**
 * 
 */
package valfazz.android.karfinder.activity;

import valfazz.android.karfinder.R;
import valfazz.android.karfinder.util.SongListView;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

/**
 * @author Val
 *
 */
public class FavoriteActivity extends Activity {
	private static final String TAG = "FavoriteActivity";
	private SongListView listView = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_favorite);
	}

	@Override
	protected void onPause() {
		Log.i(TAG, "onPause");
		super.onPause();
		listView.closeDb();
	} 

	@Override
	protected void onResume() {
		Log.i(TAG, "onResume");
		super.onResume();
		if (listView == null) {
			listView = new SongListView(this, R.id.lvFavoriteList);
		} else {
			listView.openDb();
		}
		fetchFavoriteList();
	}

	private void fetchFavoriteList() {
		listView.setQuery("select SONG_ID, SONG_TITLE, SONG_LYRICS " +
				  "from SONG where SONG_IS_FAVORITE = 1");
	}
}
